const toString = Object.prototype.toString; //  代码优化

export const isDate = (date: any): date is Date => {
  // 类型守卫
  return toString.call(date) === "[object Date]";
};

export const isObject = (obj: any): obj is Object => {
  return toString.call(obj) === "[object Object]";
};

export const extend = <T, U>(to: T, from: U): T & U => {

  const keys = Object.getOwnPropertyNames(from);
  for (let i = 0; i < keys.length; i++) {
    const key = keys[i];
    if (key != "constructor") {
      // @ts-ignore
      to[key] = from[key];
    }
  }

  return to as T & U;
};
